﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/lib/html5shiv.js"></script>
<script type="text/javascript" src="/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
	<link rel="stylesheet" type="text/css" href="/layui.css" />
<title>资讯列表</title>
	<style type="text/css" media="screen">
		a {
			color: #2B4A78;
			text-decoration: none;
		}

		a:hover {
			color: #2B4A78;
			text-decoration: underline;
		}

		a:focus, input:focus {
			outline-style: none;
			outline-width: medium;
		}

		/* custom css style: pageNum,cPageNum */
		.pageNum {
			border: 1px solid #999;
			padding: 2px 8px;
			display: inline-block;
		}

		.cPageNum {
			font-weight: bold;
			padding: 2px 5px;
		}
		#pageNav{
			-moz-user-select: none;
			-webkit-user-select: none;
			-ms-user-select: none;
		}
		#pageNav a:hover {
			text-decoration: none;
			background: #fff4d8;
		}

	</style>
	<style>
		.table{
			table-layout: fixed;
		}
		.table td:hover{
			overflow: visible;
			white-space: normal;
		}
		.table td {
			word-wrap: break-word;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	</style>
</head>
<body>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 </nav>
<div class="page-container">

	<div class="cl pd-5 bg-1 bk-gray mt-20" style="padding: 20px 20px 5px 5px;">
		<div  style=" margin:auto; width:1000px; ">
			<form class="layui-form layui-form-pane" method="post" action="/queryContentByCondition" style="height: 38px;">
				<input type="hidden" id="coin_id" name="coin_id">
				<input type="hidden" id="exchange_id" name="exchange_id">
				<input type="hidden" id="program_id" name="program_id">
				<input type="hidden" id="status" name="status">
				<div style="float: left">
					<label  class="layui-form-label" style="width: 90px;">标题</label>
					<div   class="layui-input-inline"  style="width:870px" >
						<input type="text" id="con_title" name="con_title" th:value="${contentVO.con_title}" placeholder="请输入标题" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div style="float: left">
					<label  class="layui-form-label" style="width: 90px;">选择栏目</label>
					<div   class="layui-input-inline"  style="width:135px" >
						<select lay-filter="program" >
							<option value="">请选择栏目</option>
							<option name="program" th:each="program:${contentConditionTemplateData.programList}" th:value="${program.program_id}" th:if="${program.program_id} eq ${contentVO.program_id}" th:text="${program.program_name}"  selected="selected"></option>
							<option name="program" th:each="program:${contentConditionTemplateData.programList}" th:value="${program.program_id}" th:unless="${program.program_id} eq ${contentVO.program_id}" th:text="${program.program_name}"  ></option>
						</select>
					</div>
				</div>
				<div  style="float: left">
					<label  class="layui-form-label" style="width: 90px;">选择币种</label>
					<div   class="layui-input-inline" style="width:135px"  >
						<select lay-filter="coin" lay-search="">
							<option value="">请选择币种</option>
							<option  th:each="coinTemplateData:${contentConditionTemplateData.coinTemplateDataList}" th:value="${coinTemplateData.cid}" th:if="${contentVO.coin_id }  eq ${coinTemplateData.cid}" th:text="${coinTemplateData.selectCoin} "  selected="selected"></option>
							<option  th:each="coinTemplateData:${contentConditionTemplateData.coinTemplateDataList}" th:value="${coinTemplateData.cid}" th:unless="${contentVO.coin_id }  eq ${coinTemplateData.cid}" th:text="${coinTemplateData.selectCoin}"></option>
						</select>
					</div>
				</div>
				<div  style="float: left">
					<label  class="layui-form-label" style="width: 90px;">选交易所</label>
					<div   class="layui-input-inline"  style="width:135px" >
						<select lay-filter="exchange" lay-search="">
							<option value="">请选择交易所</option>
							<option  th:each="exchange:${contentConditionTemplateData.exchangeList}" th:value="${exchange.eid}" th:if="${contentVO.exchange_id }  eq ${exchange.eid}" th:text="${exchange.ename} "  selected="selected"></option>
							<option  th:each="exchange:${contentConditionTemplateData.exchangeList}" th:value="${exchange.eid}" th:unless="${contentVO.exchange_id}  eq ${exchange.eid}" th:text="${exchange.ename}"></option>
						</select>
					</div>
				</div>
				<div  style="float: left">
					<label  class="layui-form-label" style="width: 90px;">选择状态</label>
					<div   class="layui-input-inline"  style="width:135px" >
						<select lay-filter="status" >
							<option value="">请选择状态</option>
							<option  th:each="map:${contentConditionTemplateData.statusMap}" th:value="${map.key}" th:if="${map.key}  eq ${contentVO.status}" th:text="${map.value} "  selected="selected"></option>
							<option  th:each="map:${contentConditionTemplateData.statusMap}" th:value="${map.key}" th:unless="${map.key }  eq ${contentVO.status}" th:text="${map.value}"></option>
						</select>
					</div>
				</div>
				<div class="layui-form-item"  style="float:left;clear: none;margin-bottom:0">
					<div id="button_relative">
						<button class="layui-btn" lay-submit lay-filter="aa">查询</button>
					</div>
				</div>
			</form>
		</div>
		<div style="height: 22px; text-align: right;">共有数据：<strong th:text="${total}"></strong> 条</div>
	</div>



	<div class="mt-20">
		<table id="coinTable" class="table table-border table-bordered table-bg table-hover  table-responsive">
			<thead>
				<tr class="text-c">
					<th >ID</th>
					<th>资讯标题</th>
					<th>栏目名称</th>
					<th>资讯模型</th>
					<th>阅读次数</th>
					<th>资讯作者</th>
					<th>创建时间</th>
					<th>内容</th>
					<th>发布状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="content_tbody">

				<!--<tr th:each="contentModel:${contentModelList}" class="text-c">-->
					<!--<td th:text="${contentModel.content.con_id}"></td>-->
					<!--<td th:text="${contentModel.content.con_title}"></td>-->
					<!--<td th:text="${contentModel.program.program_name}"></td>-->
					<!--<td  >-->
						<!--<span th:unless="${contentModel.coin} eq null" th:text="${contentModel.coin.cname}"></span>-->
						<!--<span th:unless="${contentModel.exchange} eq null" th:text="${contentModel.exchange.ename}"></span>-->
					<!--</td>-->
					<!--<td > &nbsp;</td>-->
					<!--<td th:text="${contentModel.content.con_author}"></td>-->
					<!--<td th:text="${contentModel.formatTime}"></td>-->
					<!--<td  ><a th:onclick="'javascript:lookArticle('+${contentModel.content.con_id}+')'" style="color: #0000cc">内容</a></td>-->
					<!--&lt;!&ndash;<td class="f-14 td-manage"><a href="javascript:void(0);"  th:onclick="'javascript:tamp('+${contentModel.content.con_id}+')'" class="btn btn-success"><i class="Hui-iconfont">&#xe68f;</i> 编辑</a>&ndash;&gt;-->
						<!--&lt;!&ndash;<a href="javaScript:void(0)"  th:onclick="'javascript:deleteContentById('+${contentModel.content.con_id}+')'"  class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>&ndash;&gt;-->
					<!--&lt;!&ndash;</td>&ndash;&gt;-->
					<!--<td th:if="${contentModel.content.status} eq 1" class="td-status"><span  class="label label-danger radius">未审核</span></td>-->
					<!--<td th:if="${contentModel.content.status} eq 2" class="td-status"><span class="label label-success radius">已发布</span></td>-->


					<!--<td class="f-14 td-manage"><a style="text-decoration:none" th:onclick="'javascript:confirm('+${contentModel.content.con_id}+')'" href="javascript:;" title="审核">审核</a>-->
					<!--<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:tamp('+${contentModel.content.con_id}+')'" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>-->
					<!--<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:updateContentStatusById('+${contentModel.content.con_id}+')'" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>-->
				<!--</tr>-->
			</tbody>
		</table>

		<script type="text/javascript" src="/pagenav1.1.cn.js"></script>
		<script type="text/javascript" src="/jquery.js"></script>
		<script th:inline="javascript" type="text/javascript">

            //$(function(){ //for jquery
			//即使是转发回这个页面也会回调此方法，所以组合条件查询时请求的controller仅是为了刷新总记录数和页面
            window.onload = (function(){
                $("#program_id").attr("value",[[${contentVO.program_id}]])
                $("#coin_id").attr("value",[[${contentVO.coin_id}]])
                $("#exchange_id").attr("value",[[${contentVO.exchange_id}]])
                $("#status").attr("value",[[${contentVO.status}]])
                //optional set
                pageNav.pre="上一页";
                pageNav.next="下一页";
                //  p,当前页码,pn,总页面
                pageNav.fn = function(p,pn){

                    // document.getElementById("test").innerHTML ="当前页:"+p+"  ,  总页: "+pn;
                    // $("#test").text("Page:"+p+" of "+pn + " pages."); // jquery调用方式
                    $.post("/queryContentByPage1", {
                            start: (p-1)*20,
                            limit:20,
							program_id:$("#program_id").val(),
							coin_id:$("#coin_id").val(),
                            exchange_id:$("#exchange_id").val(),
							status:$("#status").val(),
							con_title:$("#con_title").val()
                        },
                        function (data) {
                            var tbody=$("#content_tbody");
                            tbody.html("");
                            var trData="";

                            $.each(data, function (i, item) {
								// 对标题中含有html标签的进行转义"<"和">"转义成"&lt"和"&gt"
								var str=item.content.con_title;
                                str = str.replace(/<\/?[^>]*>/g,'');
                                trData += "<tr><td style='text-align: center'>"+ item.content.con_id +"</td><td style='text-align: center'>"+str+"</td><td style='text-align: center'>"+item.program.program_name +"</td><td style='text-align: center'>"
								if(item.coin!=null){
                                    trData+="<span>"+item.coin.cname+"</span><br/>"
								}
                                if(item.exchange!=null){
                                    trData+="<span>"+item.exchange.ename+"</span></td>"
                                }else {
                                    trData+="</td>"
                                }
                                if(item.exchange==null && item.coin==null){
                                    trData+="&nbsp;</td>";
								}
                                trData+="<td>&nbsp;</td><td style='text-align: center'>"+item.content.con_author+"</td><td style='text-align: center'>"+item.formatTime+"</td><td style='text-align: center'><a style='color: #0000cc' href='javascriptt:void(0)' onclick='lookArticle("+item.content.con_id +")'>"
                                    +"内容</a></td>"
								if(item.content.status==1){
                                    trData+="<td style='text-align: center'><span  class=\"label label-danger radius\">未审核</span></td>"
								}
                                if(item.content.status==2){
                                    trData+="<td style='text-align: center'><span class=\"label label-success radius\">已发布</span></td>"
                                }
                                if(item.content.status==3){
                                    trData+="<td style='text-align: center'><span class=\"label label-danger radius\">已删除</span></td>"
                                }
                                trData+="\t<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none\" onclick=\"confirm("+item.content.con_id+")\" href=\"javascript:void(0);\" title=\"审核\">审核</a>\n" +
                                    "\t\t\t\t\t<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"tamp("+item.content.con_id+")\" href=\"javascript:void(0);\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>\n" +
                                    "\t\t\t\t\t<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"updateContentStatusById("+item.content.con_id+")\" href=\"javascript:void(0);\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;</i></a></td>"
                            });
                            tbody.append(trData);
                        });


                };

                //每页数显示条数固定10条
                pageNav.go(1, [[${totalPage}]]);
            });
		</script>
		<!--<div id="test" style="height:70px;padding:30px 10px;font-size: 300%;"></div>-->

		<div style="float: right" id="pageNav"></div>
	</div>
</div>
<!--th:onclick="'javascript:tamp('+${mesSourceModel.mesSource.sid}+')'"-->
<!--th:onclick="'javascript:deleteById('+${mesSourceModel.mesSource.sid}+','+${mesSourceModel.typeDict.tid}+')'"-->
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/my.js"></script>
<script type="text/javascript" src="/layui.all.js"></script>


<script type="text/javascript" >
    layui.use('form', function(){
        var form = layui.form;

        form.on('select(program)', function(data){
            $("#program_id").attr("value",data.value);
        });
        form.on('select(coin)', function(data){
            $("#coin_id").attr("value",data.value);
        });
        form.on('select(exchange)', function(data){
            $("#exchange_id").attr("value",data.value);
        });
        form.on('select(status)', function(data){
            $("#status").attr("value",data.value);
        });

    });
    // 添加跳出新窗口
    function classifiedPacket_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    function classifiedPacket_update(title,url,w,h){
        layer_show(title,url,w,h)
    }
    function tamp(con_id){
        var url="/openEditContentWindow?con_id="+con_id
        classifiedPacket_add('编辑资讯',url,'800','650')
    }

    // function queryEchangeById(eid) {
    //     layer.open({
    //         type: 2,
    //         content: '/queryExchangeById?eid='+eid,
    //         area: ['800px', '500px']
    //     });
    // }
    // function queryCoinById(cid) {
    //     layer.open({
    //         type: 2,
    //         content: '/queryCoinById?cid='+cid,
    //         area: ['800px', '500px']
    //     });
    // }
    function updateContentStatusById(con_id) {
        layer.confirm("确认要删除吗", { title: "删除确认" }, function (index) {
            layer.close(index);
            $.post("/updateContentStatusById", {
                con_id: con_id,
				status:3//状态为3表示删除
				},
                function (data) {
                       var datares=eval(data)
                        layer.alert(datares.msg, {
                                title: "删除操作",
                                btn: ['确定']
                            },
                            function (index, item) {
                                //layer.close(index);
                                location.reload();
                            });
                });
        });
    }
     function lookArticle(con_id) {
                 layer.open({
                     type: 2,
                     content: '/queryContentById?con_id='+con_id,
					 title:"资讯内容",
                     area: ['800px', '600px'],
             });
     }
     function confirm(con_id) {
         layer.confirm('文章审核？', {
             btn: ['通过', '不通过', '取消'] //可以无限个按钮
         }, function(index, layero){
             $.post("/updateContentStatusById", {
                 con_id: con_id,
				 status:2//状态为2表示已审核通过，已发布状态
				 },
                 function (data) {
                    var datares=eval(data);
                     layer.alert(datares.msg, {
                             title: "修改文章状态操作",
                             btn: ['确定']
                         },
                         function (index, item) {
                             //layer.close(index);
                             location.reload();
                         });
                 });
         }, function(index){
             $.post("/updateContentStatusById", {
                     con_id: con_id,
                     status:1//默认状态表示未审核，用户不可看
                 },
                 function (data) {
                     var datares=eval(data);
                     layer.alert(datares.msg, {
                             title: "修改文章状态操作",
                             btn: ['确定']
                         },
                         function (index, item) {
                             //layer.close(index);
                             location.reload();
                         });
                 });
         });
     }
</script>
</body>
</html>